<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<FiltronASP.Areas.Admin.ViewModels.Menus.MenusIndexViewModel>" %>
<%@ Import Namespace="FiltronASP.Helpers.HtmlTags" %>
<%@ Import Namespace="FiltronASP.Helpers.Routes" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Zarządzanie elementami menu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="right-page-buttons2">
        <% Html.RenderPartial("TopIndexButtons"); %>
    </div>  
    <table class="right-pages">
	    <tbody>
	        <% if (Model.CurrentMenu == null) { %>
                <tr class="right-row">
                    <td class="right-cell-big">Nie wybrano grupy menu.</td>
                </tr>            
            <% }
            else if ((Model.PaginatedMenuItems == null) || (Model.PaginatedMenuItems.Count == 0))
            { //if null   %>
                <tr class="right-row">
                    <td class="right-cell-big">Brak elementów do wyświetlenia.</td>
                </tr>
            <% }
            else if (Model.CurrentLanguage == null)
            { //if null   %>
                <tr class="right-row">
                    <td class="right-cell-big">Brak elementów do wyświetlenia.</td>
                </tr>            <% 
            } else { //if menuItem type null   %>
                <% foreach (var menuItem in Model.PaginatedMenuItems)
                   { %>
                    <% if ((Model.PaginatedMenuItems.IndexOf(menuItem) % 2) == 0)
                       { %>
                        <tr class="right-row">
                            <td class="right-cell-big">
                                <% if (menuItem.MenuItemType != null) { %>
                                    <% if (!(String.IsNullOrEmpty(menuItem.MenuItemType.type_img))) { %>                                   
                                        <img src="<%= Url.GenerateAdminImageLink(menuItem.MenuItemType.type_img) %>" alt=" " />
                                    <% } //if img %>                            
                                    <% if (menuItem.MenuItemType.type_abbr == "FLD") { %>
                                        <a href="<%= Url.GenerateMenusListRoute(Model.CurrentMenu, menuItem , Model.CurrentLanguage) %>">
			                                <%= menuItem.item_name %>
			                            </a>
                                    <% } else { //if folder %>  
                                        <%= menuItem.item_name %>
                                    <% }    //else folder     %>                               
                                <% }    //if not null     %>                                                                   
					        </td>
					        <td class="right-cell-small">
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != 0) { %>
					                <%= Html.ActionLinkWithImage("admin-right-up1.png",
                                                                                String.Empty, "MenuItemOneUp", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id), 
                                            currentMenuId = (Model.CurrentMenu.menu_id),
                                            currentMenuItemId = (menuItem.parent_item_id),
                                            currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if not first %>
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != (Model.PaginatedMenuItems.Count - 1)) { %>
					                <%= Html.ActionLinkWithImage("admin-right-down1.png",
                                                                                String.Empty, "MenuItemOneDown", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id), 
                                            currentMenuId = (Model.CurrentMenu.menu_id),
                                            currentMenuItemId = (menuItem.parent_item_id),
                                            currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-small">
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != 0) { %>
					                <%= Html.ActionLinkWithImage("admin-right-uptop.png",
                                                                                String.Empty, "MenuItemTopUp", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id),
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id),
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                                })%>    
					            <% } //if not first %>
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != (Model.PaginatedMenuItems.Count - 1)) { %>
					                <%= Html.ActionLinkWithImage("admin-right-downbottom.png",
                                                                                String.Empty, "MenuItemBottomDown", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id),
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id),
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                                })%>    
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_removable) { %>
					                <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "DeleteMenuItem", new
                                                    {
                                                        menuItemToDeleteId = (menuItem.item_id),
                                                        currentMenuId = (Model.CurrentMenu.menu_id),
                                                        currentMenuItemId = (menuItem.parent_item_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                        paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                    } )%>    
					            <% } //if removable %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_editable) { %>
					                <%= Html.ActionLinkWithImage("admin-right-edit.png", 
					                    " Edytuj", "EditMenuItem", new { menuItemToEditId = (menuItem.item_id),
                                                                    currentMenuId = (Model.CurrentMenu.menu_id), 
                                            currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if removable %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_published) { %>
					                <%= Html.ActionLinkWithImage("admin-right-published.png",
                                                                                " Ukryj", "HideMenuItem", new
                                                                                {
                                                                                    menuItemToHideId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id), 
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } else { //if published %>
					                <%= Html.ActionLinkWithImage("admin-right-unpublished.png", 
					                                                        " Publikuj", "PublishMenuItem", new 
                                                                            { 
                                                                                menuItemToPublishId = (menuItem.item_id),
                                                                                currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                currentMenuItemId = (menuItem.parent_item_id), 
                                                                                currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                                                paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                            } )%>    
					            <% } //if hidden %>
					        </td>
                        </tr>					       
                    <% } else { //if odd row %>                       
                        <tr class="right-row altrow">
                            <td class="right-cell-big">
                                <% if (menuItem.MenuItemType != null) { %>
                                    <% if (!(String.IsNullOrEmpty(menuItem.MenuItemType.type_img))) { %>                                   
                                        <img src="<%= Url.GenerateAdminImageLink(menuItem.MenuItemType.type_img) %>" alt=" " />
                                    <% } //if img %>                            
                                    <% if (menuItem.MenuItemType.type_abbr == "FLD") { %>
                                        <a href="<%= Url.GenerateMenusListRoute(Model.CurrentMenu, menuItem , Model.CurrentLanguage) %>">
			                                <%= menuItem.item_name %>
			                            </a>
                                    <% } else { //if folder %>  
                                        <%= menuItem.item_name %>
                                    <% }    //else folder     %>                               
                                <% }    //if not null     %>                                                                   
					        </td>
					        <td class="right-cell-small">
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != 0) { %>
					                <%= Html.ActionLinkWithImage("admin-right-up1.png", 
					                    String.Empty, "MenuItemOneUp", new { menuItemToMoveId = (menuItem.item_id),
                                                                         currentMenuId = (Model.CurrentMenu.menu_id),
                                                                             currentMenuItemId = (menuItem.parent_item_id),
                                                                             currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if not first %>
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != (Model.PaginatedMenuItems.Count - 1)) { %>
					                <%= Html.ActionLinkWithImage("admin-right-down1.png", 
					                    String.Empty, "MenuItemOneDown", new { menuItemToMoveId = (menuItem.item_id),
                                                                           currentMenuId = (Model.CurrentMenu.menu_id),
                                                                           currentMenuItemId = (menuItem.parent_item_id), 
                                            currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-small">
				            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != 0) { %>
					                <%= Html.ActionLinkWithImage("admin-right-uptop.png",
                                                                                String.Empty, "MenuItemTopUp", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id),
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id),
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                                })%>    
					            <% } //if not first %>
					            <% if (Model.PaginatedMenuItems.IndexOf(menuItem) != (Model.PaginatedMenuItems.Count - 1)) { %>
					                <%= Html.ActionLinkWithImage("admin-right-downbottom.png",
                                                                                String.Empty, "MenuItemBottomDown", new
                                                                                {
                                                                                    menuItemToMoveId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id),
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id),
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                                })%>    
					            <% } //if not last %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_removable) { %>
					                <%= Html.ActionLinkWithImage("admin-right-remove.png",
                                                    " Usuń", "DeleteMenuItem", new
                                                    {
                                                        menuItemToDeleteId = (menuItem.item_id),
                                                        currentMenuId = (Model.CurrentMenu.menu_id),
                                                        currentMenuItemId = (menuItem.parent_item_id),
                                                        currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                        paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                    } )%>    
					            <% } //if removable %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_editable) { %>
					                <%= Html.ActionLinkWithImage("admin-right-edit.png", 
					                    " Edytuj", "EditMenuItem", new { menuItemToEditId = (menuItem.item_id),
                                                                    currentMenuId = (Model.CurrentMenu.menu_id), 
                                            currentLanguageId = (Model.CurrentLanguage.language_id), 
                                            paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } //if removable %>
					        </td>
					        <td class="right-cell-mid">
					            <% if (menuItem.item_published) { %>
					                <%= Html.ActionLinkWithImage("admin-right-published.png",
                                                                                " Ukryj", "HideMenuItem", new
                                                                                {
                                                                                    menuItemToHideId = (menuItem.item_id),
                                                                                    currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                    currentMenuItemId = (menuItem.parent_item_id), 
                                                                                    currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                                                    paginationPage = (Model.PaginatedMenuItems.PageIndex)} )%>    
					            <% } else { //if published %>
					                <%= Html.ActionLinkWithImage("admin-right-unpublished.png", 
					                                                        " Publikuj", "PublishMenuItem", new 
                                                                            { 
                                                                                menuItemToPublishId = (menuItem.item_id),
                                                                                currentMenuId = (Model.CurrentMenu.menu_id),
                                                                                currentMenuItemId = (menuItem.parent_item_id), 
                                                                                currentLanguageId = (Model.CurrentLanguage.language_id), 
                                                                                paginationPage = (Model.PaginatedMenuItems.PageIndex)
                                                                            } )%>    
					            <% } //if hidden %>
					        </td>
                        </tr>					       
                    <% } //else odd row %>                       
                <% }    //foreach %>
            <% }    //else null %>
	    </tbody>
    </table>
    <div class="right-pagination">
        <% if ((Model.PaginatedMenuItems != null) && (Model.PaginatedMenuItems.Count > 0)) { %>
            <% if (Model.PaginatedMenuItems.HasPreviousPage) { %>                
                <a href="<%= Url.GenerateMenusListRoute(1, Model.CurrentMenu, Model.CurrentMenuItem, Model.CurrentLanguage) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-first.png")%>" alt="pierwsza" />
                </a>
                <a href="<%= Url.GenerateMenusListRoute(Model.PaginatedMenuItems.PageIndex - 1, Model.CurrentMenu, Model.CurrentMenuItem, Model.CurrentLanguage) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-prev.png")%>" alt="poprzednia" />
                </a>
            <% } //if prev %>
            <% if ((Model.PaginatedMenuItems.HasPreviousPage) || (Model.PaginatedMenuItems.HasNextPage)) { %>
                &nbsp;&nbsp;
                Strona <%= Model.PaginatedMenuItems.PageIndex%> z <%= Model.PaginatedMenuItems.PagesCount%>
                &nbsp;&nbsp;
            <% } //if %>
            <% if (Model.PaginatedMenuItems.HasNextPage) { %>
                <a href="<%= Url.GenerateMenusListRoute(Model.PaginatedMenuItems.PageIndex + 1, Model.CurrentMenu, Model.CurrentMenuItem, Model.CurrentLanguage) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-next.png")%>" alt="następna" />
                </a>
                <a href="<%= Url.GenerateMenusListRoute(Model.PaginatedMenuItems.PagesCount, Model.CurrentMenu, Model.CurrentMenuItem, Model.CurrentLanguage) %>">
                    <img src="<%= Url.GenerateAdminImageLink("admin-right-last.png")%>" alt="ostatnia" />
                </a>
            <% } //if next %>    
        <% } //if not null and not empty %>    
    </div>    	                   
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
    <% if (Model.CurrentMenu == null) { %>	
        Zarządzanie elementami menu
    <% } else { //if null %>        
        <%= Model.CurrentMenu.menu_name %>
    <% } //else null %>        
</asp:Content>
